package fr.oz.mobile.home 
{
	import caurina.transitions.Tweener;
	import flash.display.Sprite;
	import flash.events.GestureEvent;
	import flash.events.MouseEvent;
	import flash.events.TouchEvent;
	import fr.digitas.flowearth.conf.Conf;
	import fr.oz.core.events.ModuleEvent;
	import fr.oz.mobile.common.ui.NavSeparator;
	/**
	 * ...
	 * @author Fazermokeur
	 */
	public class HomeNav extends Sprite
	{
		private var a_navItem:Array = [];
		
		public function HomeNav() 
		{
			var node:XML;
			var item:HomeNavItem;
			var len:int = Conf.getDatas("common").mainMenu.item.length();
			trace("len : " + len);
			var cpt:int = 0;
			var posY:int = 0;
			for each (node in Conf.getDatas("common").mainMenu.item) 
			{
				item = new HomeNavItem(node.@id, node);
				addChild(item);
				item.y = posY;
				item.alpha = 0;
				
				Tweener.addTween(item, {alpha:1, time:.8, delay:cpt*.1 } );
				
				posY += item.height + 40;
				if (cpt < len)
				{
					var separator:NavSeparator = new NavSeparator();
					addChild(separator);
					separator.y = posY - 20;
					separator.alpha = 0;
					Tweener.addTween(separator, {alpha:1, time:.9, delay:cpt*.1 } );
				}
				
				item.addEventListener(MouseEvent.CLICK, handleSelectModule);
				
				a_navItem.push(item);
				cpt++;
			}
			
		}
		
		private function handleSelectModule(e:MouseEvent):void 
		{
			dispatchEvent(new ModuleEvent(ModuleEvent.MODULE_SELECTED, (e.currentTarget as HomeNavItem).id, true));
		}
		
	}

}